PHP

How to demonstrate the json_encode() function with indexed array of strings in PHP | PHP program

How to demonstrate the json_encode() function with indexed array of strings in PHP | PHP program

How to demonstrate the json_encode() function with indexed array of strings in PHP | PHP program

We will create an indexed array that contains the name of countries and then convert the array into JSON format using json_encode() function.

<?php

//function with indexed array of strings.
$Countries = array(
    "INDIA",
    "AUSTRALIA",
    "USA",
    "RUSSIA"
);
$jsonStr = json_encode($Countries);
printf("Result: %s<br>", $jsonStr);
?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community